跳到主要内容

SetTextPr

Sets the text properties to the current run.

Syntax

expression.SetTextPr(oTextPr);

expression - A variable that represents a ApiRun class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oTextPrRequiredApiTextPrThe text properties that will be set to the current run.

Returns

ApiTextPr

Example

This example sets the text properties to the current run.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text with the font size set to 30 and the font weight set to bold.");
paragraph.AddElement(run);
let textPr = Api.CreateTextPr();
textPr.SetFontSize(30);
textPr.SetBold(true);
run.SetTextPr(textPr);